/*
 * Created by JFormDesigner on Mon Apr 26 18:14:59 CST 2021
 */

package com.lgz.dbcourse.gui;

import com.lgz.dbcourse.service.UserService;
import com.lgz.dbcourse.service.impl.UserServiceImpl;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author unknown
 */
public class UserFrame extends MyFrame {


    public UserFrame() {
        initComponents();
    }

    public void start() {
       this.setVisible(true);
    }

    private void button1ActionPerformed(ActionEvent e) {
        // TODO add your code here
        String phone = this.textField1.getText();
        try {
            if (phone.length() != 11) {
                new Error(this, "请输入正确的手机号").start();
            } else {
                Double.parseDouble(phone);
                new UF(phone).start();
                // 关闭窗口
                JButton jButton = (JButton) e.getSource();
                Container container = jButton.getParent();
                while (!(container instanceof JFrame)) {
                    container = container.getParent();
                }
                ((JFrame)container).dispose();

            }
        } catch (Exception e1) {
            e1.printStackTrace();
            new Error(this, "请输入正确的手机号").start();
        }
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        panel5 = new JPanel();
        panel6 = new JPanel();
        panel7 = new JPanel();
        panel8 = new JPanel();
        center = new JPanel();
        label1 = new JLabel();
        panel9 = new JPanel();
        label2 = new JLabel();
        panel10 = new JPanel();
        panel12 = new JPanel();
        panel13 = new JPanel();
        button1 = new JButton();
        panel11 = new JPanel();
        textField1 = new JTextField();
        panel14 = new JPanel();
        panel15 = new JPanel();
        panel16 = new JPanel();
        panel17 = new JPanel();

        //======== this ========
        setTitle("\u7528\u6237\u767b\u5f55");
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== panel5 ========
        {
            panel5.setPreferredSize(new Dimension(0, 60));
            panel5.setLayout(new BorderLayout());
        }
        contentPane.add(panel5, BorderLayout.NORTH);

        //======== panel6 ========
        {
            panel6.setMinimumSize(new Dimension(30, 0));
            panel6.setPreferredSize(new Dimension(30, 0));
            panel6.setLayout(new BorderLayout());
        }
        contentPane.add(panel6, BorderLayout.WEST);

        //======== panel7 ========
        {
            panel7.setMinimumSize(new Dimension(30, 0));
            panel7.setPreferredSize(new Dimension(30, 0));
            panel7.setLayout(new BorderLayout());
        }
        contentPane.add(panel7, BorderLayout.EAST);

        //======== panel8 ========
        {
            panel8.setPreferredSize(new Dimension(0, 60));
            panel8.setLayout(new BorderLayout());
        }
        contentPane.add(panel8, BorderLayout.SOUTH);

        //======== center ========
        {
            center.setLayout(new BorderLayout());

            //---- label1 ----
            label1.setHorizontalAlignment(SwingConstants.CENTER);
            center.add(label1, BorderLayout.NORTH);

            //======== panel9 ========
            {
                panel9.setLayout(new GridLayout(1, 1, 0, 100));

                //---- label2 ----
                label2.setText("\u624b\u673a\u53f7");
                panel9.add(label2);
            }
            center.add(panel9, BorderLayout.WEST);

            //======== panel10 ========
            {
                panel10.setLayout(new BorderLayout());

                //======== panel12 ========
                {
                    panel12.setPreferredSize(new Dimension(180, 30));
                    panel12.setLayout(new BorderLayout(40, 40));
                }
                panel10.add(panel12, BorderLayout.WEST);

                //======== panel13 ========
                {
                    panel13.setPreferredSize(new Dimension(180, 30));
                    panel13.setLayout(new BorderLayout(40, 40));
                }
                panel10.add(panel13, BorderLayout.EAST);

                //---- button1 ----
                button1.setText("\u767b\u5f55");
                button1.addActionListener(e -> button1ActionPerformed(e));
                panel10.add(button1, BorderLayout.CENTER);
            }
            center.add(panel10, BorderLayout.SOUTH);

            //======== panel11 ========
            {
                panel11.setLayout(new BorderLayout());

                //---- textField1 ----
                textField1.setPreferredSize(new Dimension(160, 30));
                panel11.add(textField1, BorderLayout.CENTER);

                //======== panel14 ========
                {
                    panel14.setPreferredSize(new Dimension(20, 0));
                    panel14.setLayout(new BorderLayout());
                }
                panel11.add(panel14, BorderLayout.WEST);

                //======== panel15 ========
                {
                    panel15.setPreferredSize(new Dimension(20, 0));
                    panel15.setLayout(new BorderLayout());
                }
                panel11.add(panel15, BorderLayout.EAST);

                //======== panel16 ========
                {
                    panel16.setPreferredSize(new Dimension(0, 100));
                    panel16.setLayout(new BorderLayout());
                }
                panel11.add(panel16, BorderLayout.SOUTH);

                //======== panel17 ========
                {
                    panel17.setPreferredSize(new Dimension(0, 100));
                    panel17.setLayout(new BorderLayout());
                }
                panel11.add(panel17, BorderLayout.NORTH);
            }
            center.add(panel11, BorderLayout.CENTER);
        }
        contentPane.add(center, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JPanel panel5;
    private JPanel panel6;
    private JPanel panel7;
    private JPanel panel8;
    private JPanel center;
    private JLabel label1;
    private JPanel panel9;
    private JLabel label2;
    private JPanel panel10;
    private JPanel panel12;
    private JPanel panel13;
    private JButton button1;
    private JPanel panel11;
    private JTextField textField1;
    private JPanel panel14;
    private JPanel panel15;
    private JPanel panel16;
    private JPanel panel17;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
